<%@ page language="java" contentType="text/html;charset=UTF-8"%>
<%@ include file="/static/include/taglib.jsp"%>
<!DOCTYPE html >
<html>
<head>
 <meta name="viewport" content="width=device-width" />
 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />  
 <title>后台管理--模板编辑</title>
  <link href="${ctxStatic}/ligeruilib/ligerUI/skins/Aqua/css/ligerui-all.css" rel="stylesheet" type="text/css">
 <link href="${ctxStatic}/layui/css/layui.css" rel="stylesheet" />
 <link href="${ctxStatic}/css/kpiuitanchu.css" rel="stylesheet" />
 <script src="${ctxStatic}/js/jquery-1.8.3.min.js?v=2.0" type="text/javascript"></script>
 <script src="${ctxStatic}/layui/layui.all.js"  type="text/javascript"></script>
 <script src="${ctxStatic}/ligeruilib/ligerUI/js/core/base.js" type="text/javascript"></script>
 <script src="${ctxStatic}/ligeruilib/ligerUI/js/plugins/ligerTree.js" type="text/javascript"></script>
 <script src="${ctxStatic}/ligeruilib/ligerUI/js/plugins/ligerComboBox.js" type="text/javascript"></script>
 <script>
 $(function(){
		
		 
		 
		$("#parentid").ligerComboBox({ 
		 data: null, 
		 valueField: 'assindexid',
        textField: 'uasscontent', 
        selectBoxWidth : 478,
		 selectBoxHeight:390,
        autocomplete: true,
        width: 470,
        onSelected: function(assindexid, uasscontent){//id为空值，name为选择的值  
        	//alert(assindexid);
        	$("#hidparentid").val(assindexid);
        },
	 })
	})
 </script>
</head>
<body>
 <div class="tanchucontent">
   <form class="layui-form" id="formedit" name="formedit" action="add_templateindex" method="post" target="d41d8cd98f00b204e9800998ecf8427e">
    <iframe name="d41d8cd98f00b204e9800998ecf8427e" src="about:blank" style="display:none;"></iframe>
     <table>
      <tr>
       <td class="td_right">类型：</td>
       <td>
        <c:if test="${entity.assindextype == 0}">
         <input type="radio" name="assindextype" value="0" lay-filter="assindextype" title="内容" checked="">
         <input type="radio" name="assindextype" value="1" lay-filter="assindextype" title="指标">
        </c:if>
        <c:if test="${entity.assindextype == 1}">
         <input type="radio" name="assindextype" value="0" lay-filter="assindextype" title="内容" >
         <input type="radio" name="assindextype" value="1" lay-filter="assindextype" title="指标" checked="">
        </c:if>
         
         <!-- <input type="radio" name="assindextype" value="2" title="标准"> -->
       </td>
      </tr>
      <!-- <tr>
       <td class="td_right">组别：</td>
       <td>
          <select name="groupid" id="groupid" lay-verify="required" lay-filter="groupid">
           <option value="">请选择</option>
            <c:forEach var="item" items="${lstorg}">
             <option value="${item.orgid}">${item.orgname}</option>
            </c:forEach>
          </select>
       </td>
      </tr> -->
      <tr id="trparentid">
       <td class="td_right">上级：</td>
       <td>
         <!-- <select name="parentid" lay-verify="required">
                <option value="0">请选择上级</option>
                <c:forEach var="item" items="${lst}">
                 <c:if test="${entity.parentid == item.assindexid}">
                  <option selected="selected" value="${item.assindexid}">${item.uasscontent}</option>
                 </c:if>
                 <c:if test="${entity.parentid != item.assindexid}">
                  <option value="${item.assindexid}">${item.uasscontent}</option>
                 </c:if>
                  
                </c:forEach>
              </select> -->
         <input type="text" id="parentid"  style="padding-left:10px;" class="layui-input" >
         <input type="hidden" id="hidparentid" name="parentid" value="${entity.parentid}">
       </td>
      </tr>
       <tr>
       <td class="td_right">内容：</td>
       <td>
        <c:if test="${entity.assindextype == 0}">
         <input type="text" name="uasscontent" lay-verify="required" autocomplete="off" class="layui-input" value="${entity.uasscontent }" >
        </c:if>
        <c:if test="${entity.assindextype == 1}">
         <input type="text" name="uasscontent" lay-verify="required" autocomplete="off" class="layui-input" value="${entity.uassingredients }" >
        </c:if>
         
       </td>
      </tr>
      <tr id="trscore">
       <td class="td_right">分数：</td>
       <td>
        <input type="text" readonly="readonly" id="score" name="score" lay-verify="required|number" autocomplete="off" class="layui-input" value="${entity.score }" >
       </td>
      </tr>
      <tr id="trevaluationstandard">
       <td class="td_right">评价标准：</td>
       <td>
         <textarea class="layui-textarea" readonly="readonly" id="evaluationstandard"  name="evaluationstandard" >${entity.evaluationstandard }</textarea>
       </td>
      </tr>
       <tr>
       <td colspan="2" style="text-align: center;padding-top:10px">
         <button class="button" lay-submit="" lay-filter="demo1" id="btnsave">保存</button>
		 <input type="button" value="关闭" class="button" onclick="parent.CloseWin()"/>
       </td>
      </tr>
     </table>
     
     
     
     
     
  
     
    <input type="hidden" name="assindexid" id="assindexid" value="${entity.assindexid }"/>
      <input type="hidden" name="templateid" id="templateid" value="${templateid}"/>
    <input type="hidden" id="groupidsub" name="groupidsub" value="${groupid}"/>
    
  </form>
   <input type="hidden" id="hidgroupid" value="${entity.groupid }"/>
    <input type="hidden" id="hidassindextype" value="${ entity.assindextype}"/>
    
     <input type="hidden" id="hidmodelgroupid" value="${groupid}"/>
 
  
  <script>
  $(function(){
	  
	  liger.get("parentid").setDisabled();
	  if($("#hidassindextype").val()==0){
		  $("#trparentid").hide();
		  $("#trscore").hide();
		  $("#trevaluationstandard").hide();
	  }
	  
	
	  if($("#assindexid").val()>0){
		  $("#evaluationstandard").removeAttr("readonly").removeAttr("title");
		  $("#score").removeAttr("readonly").removeAttr("title");
	  }
	  
	  
	  InitParent();
	  
  })
  
  function InitParent(){
	  $.ajax({
			 url:"get_index_list?groupid="+$("#hidmodelgroupid").val()+"&templateid="+$("#templateid").val(),
			 type:"get",
			 success:function(data){
				 orgdata=eval('('+data+')');
				 liger.get("parentid").setData(orgdata);
				 
			 }
		 })
  }
  
  layui.use('form', function(){
	 var form = layui.form;
	 form.on('submit(demo1)', function(data){
		 if(data.field.assindextype==1){
			 if(data.field.parentid==0){
				 alert('请选择上级');
				 return false;
			 }
		 }
		 else{
			 if(data.field.parentid!=0){
				 alert('内容项不需要上级');
				 return false;
			 }
		 }
		 return true;
	 })
	
	  form.on('radio(assindextype)', function(data){
		  if(data.value==1){
			  $("#evaluationstandard").removeAttr("readonly").removeAttr("title");
			  $("#score").removeAttr("readonly").removeAttr("title");
			 // $("#parentid").removeAttr("disabled");
			 liger.get("parentid").setEnabled();
			 $("#trparentid").show();
			  $("#trscore").show();
			  $("#trevaluationstandard").show();
		  }
		  else{
			  $("#evaluationstandard").attr("readonly","readonly").attr("title","不可用");
			  $("#score").attr("readonly","readonly").attr("title","不可用");
			  liger.get("parentid").setDisabled();
			  $("#trparentid").hide();
			  $("#trscore").hide();
			  $("#trevaluationstandard").hide();
		  }
	  })
	 
	  form.on('select(groupid)', function(data){
		  $.ajax({
				 url:"get_index_list?groupid="+data.value+"&templateid="+$("#templateid").val(),
				 type:"get",
				 success:function(data){
					 orgdata=eval('('+data+')');
					 liger.get("parentid").setData(orgdata);
					 
				 }
			 })
       })
       //alert($("#hidgroupid").val());
       $("#groupid").val($("#hidgroupid").val());
       
       if($("#hidgroupid").val()>0){
    	   $.ajax({
				 url:"../common/get_index_list?groupid="+$("#hidgroupid").val(),
				 type:"get",
				 success:function(data){
					 orgdata=eval('('+data+')');
					 liger.get("parentid").setData(orgdata); 
                     if($("#hidparentid").val()>0){
                    	 liger.get("parentid").setValue($("#hidparentid").val());
					 }
				 }
			 })
       }
       
	 form.render('select');
	 form.render();
  });
 
 function CloseDialog(result,msg){
	  //top.frames["iframe"].vTemplate.addresult(result,msg);
	 parent.addresult(result,msg);
 }
  </script>
 </div>
</body>
</html>